package test;

import generator.MappingGenerator;

import java.net.URI;

import matching.ClassTriple;
import matching.DataPropertyTriple;
import matching.Matching;
import matching.Restriction;
import matching.VocabularyMatching;
import matching.Triple;
import matching.propertyPath.Property;
import matching.propertyPath.PropertyPath;

import org.coode.xml.OWLOntologyNamespaceManager;
import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLDataFactory;
import org.semanticweb.owl.model.OWLDataProperty;
import org.semanticweb.owl.model.OWLObjectProperty;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyManager;

public class teste { 
	public static void main(String[] args) {
		OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
		OWLDataFactory dataFactory = manager.getOWLDataFactory();
		//String base = "am";
		//PrefixManager pm = new DefaultPrefixManager(base);
		
		
		try{
			Matching m1;
			Triple s1, t1;
			URI uriE = URI.create("file:///E:/livia/workspace/CID/ontologies/Ebay.owl");
			URI uriD = URI.create("file:///E:/livia/workspace/CID/ontologies/domain.owl");
			URI uriA = URI.create("file:///E:/livia/workspace/CID/ontologies/Amazon.owl");
			
			
			//ufc
			//file:///C:/Documents%20and%20Settings/livia/Meus%20documentos/workspace/CID/ontologies/Ebay.owl
			//file:///C:/Documents%20and%20Settings/livia/Meus%20documentos/workspace/CID/ontologies/domain.owl
			// casa
			//file:///E:/livia/workspace/CID/ontologies/Ebay.owl
			//file:///E:/livia/workspace/CID/ontologies/domain.owl
			OWLOntology amazon = manager.loadOntologyFromPhysicalURI(uriE);
			OWLOntology ebay = manager.loadOntologyFromPhysicalURI(uriE);
			OWLOntology domain = manager.loadOntologyFromPhysicalURI(uriD);
			
			OWLOntologyNamespaceManager ebayN = new OWLOntologyNamespaceManager(manager,ebay); 
			OWLOntologyNamespaceManager domainN = new OWLOntologyNamespaceManager(manager,domain); 
			OWLOntologyNamespaceManager amazonN = new OWLOntologyNamespaceManager(manager,amazon); 
			
			VocabularyMatching v = new VocabularyMatching(ebay, domain, "eb","do");
			MappingGenerator g = new MappingGenerator(v);
			
			//teste 1
			//
			/*OWLClass elem = dataFactory.getOWLClass(new URI(ebay.getURI()+"#Product"));
			OWLDataProperty restAtr = dataFactory.getOWLDataProperty(new URI(ebay.getURI()+"#type"));
			OWLClass elem2 = dataFactory.getOWLClass(new URI(domain.getURI()+"#Book"));
			s1 = new ClassTriple(elem, new Restriction(restAtr, "book"));
			t1 = new ClassTriple(elem2, null);
			m1 = new Matching(s1,t1);	
			System.out.println("match:\n"+m1);
			g.insertRuleCase1(m1);
			
			
			//teste 3
			//
			OWLDataProperty elem3 = dataFactory.getOWLDataProperty(new URI(ebay.getURI()+"#title"));
			OWLDataProperty elem4 = dataFactory.getOWLDataProperty(new URI(ebay.getURI()+"#title"));
			s1 = new DataPropertyTriple(elem3,elem,new Restriction(restAtr, "book"));
			t1 = new DataPropertyTriple(elem4,elem2,null);
			m1 = new Matching(s1,t1);	
			System.out.println("match:\n"+m1);
			g.insertRuleCase3(m1);*/
			
			//teste 4
			//
			PropertyPath path = new PropertyPath();
			OWLDataProperty s = dataFactory.getOWLDataProperty(new URI(domain.getURI()+"#recname"));
			OWLDataProperty t = dataFactory.getOWLDataProperty(new URI(amazon.getURI()+"#recorder"));
			OWLObjectProperty p1 = dataFactory.getOWLObjectProperty(new URI(amazon.getURI()+"#rec"));
			
			OWLClass dp2 = dataFactory.getOWLClass(new URI(amazon.getURI()+"#Recorder"));
			OWLClass cs = dataFactory.getOWLClass(new URI(domain.getURI()+"#Recorder"));
			OWLClass ct = dataFactory.getOWLClass(new URI(amazon.getURI()+"#Music"));
			s1 = new DataPropertyTriple(s,cs,null);
			t1 = new DataPropertyTriple(t,ct,null);
			m1 = new Matching(s1,t1);
			System.out.println("match 4:\n"+m1);
			
			//path.addLink(new Property(s,s.getd, ));
			
			
			//OWLObjectProperty p1 = dataFactory.getOWLObjectProperty(new URI(ebay.getURI()+"#rec"));
			path.addLink(new Property(p1, ct, cs));
			
			//s1 = new DataPropertyTriple(dataFactory.getOWLDataProperty(URI.create(uriA.toString()+"#tittle")),bookA, null);
			//t1 = new DataPropertyTriple(dataFactory.getOWLDataProperty(URI.create(uriD.toString()+"#tittle")),bookD, null);
			
			System.out.println(g.sm);
			
		}catch (Exception e) {
			e.printStackTrace();
			e.printStackTrace();
		}
		
	}
	
	
	
	
}
